'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.condition = exports.conditionObject = exports.conditionArray = undefined;

var _filter = require('lodash/filter');

var _filter2 = _interopRequireDefault(_filter);

var _pickBy = require('lodash/pickBy');

var _pickBy2 = _interopRequireDefault(_pickBy);

var _findIndex = require('lodash/findIndex');

var _findIndex2 = _interopRequireDefault(_findIndex);

var _isFunction = require('lodash/isFunction');

var _isFunction2 = _interopRequireDefault(_isFunction);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var flag = {};
var conditionArray = exports.conditionArray = function conditionArray(array) {
    return (0, _filter2.default)(array, function (item) {
        return !(item === flag);
    });
};
var conditionObject = exports.conditionObject = function conditionObject(object) {
    return (0, _pickBy2.default)(object, function (item) {
        return !(item === flag);
    });
};
var condition = exports.condition = function condition(val) {
    for (var _len = arguments.length, conditions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        conditions[_key - 1] = arguments[_key];
    }

    var falseIndex = (0, _findIndex2.default)(conditions, function (cond) {
        if ((0, _isFunction2.default)(cond)) {
            return !cond(val);
        }
        return !cond;
    });
    return falseIndex > -1 ? flag : val;
};